import os

txt = """"""


def print_directory_tree(root_dir, level=0, ignore_dirs=None, ignore_files=None):
	"""
	:param root_dir: 要打印的目录
	:param level: 用于记录当前的层级，用于控制打印时的缩进
	:param ignore_dirs: 要忽略的目录
	:param ignore_files: 要忽略的文件
	:return:
	"""
	global txt
	if ignore_files is None:
		ignore_files = []
	if ignore_dirs is None:
		ignore_dirs = []
	for item in os.listdir(root_dir):
		if item in ignore_dirs:
			continue
		if os.path.isfile(os.path.join(root_dir, item)):
			if item not in ignore_files:
				txt += "|   " * level + "|-- " + item + "\n"
				print("|   " * level + "|-- " + item)
		else:
			txt += "|   " * level + "|-- " + item + "/" + "\n"
			print("|   " * level + "|-- " + item + "/")
			print_directory_tree(os.path.join(root_dir, item), level + 1, ignore_dirs, ignore_files)


print_directory_tree("./", ignore_dirs=[".git", ".idea"], ignore_files=["README.md", ".gitignore"])
# print_directory_tree("./")
if txt:
	with open("tmp.txt", 'w', encoding='utf-8') as f:
		f.write(txt)
